package Test;

import CODEC.Decoding;
import CODEC.Encoding;
import CODEC.Impl.DecodingImpl;
import CODEC.Impl.EncodingImpl;
import Utils.Util;
import domain.Message;
import domain.PDU.PDU;
import domain.PDU.Tag.TagType;
import domain.PDU.VariableBindings;
import org.junit.Test;
import Utils.*;
import java.util.*;

/**
 * @Author: ylc
 * @Description:
 */
public class test {
    Encoding encoder = new EncodingImpl();
    Decoding decoder = new DecodingImpl();
    Util util = new Util();
    EncodingUtil enutil = new EncodingUtil();
    HashMap<String, Byte> tagCoding = TagType.getTagCoding();


    // 编码test
    @Test
    public void test1(){
        VariableBindings var1 = new VariableBindings("2.1.11.8.0", "NULL", "0");
        PDU pdu = new PDU("get-request","15","noError","noError", var1);
        Message snmp = new Message("version-1","ylc",pdu);
        byte[] temp = encoder.getSnmpMessageCoding(snmp);
        System.out.println(temp.length);
        Util.showPacket(temp);
    }
    // 解码test
    @Test
    public void test2(){
        byte[] b = new byte[]{0x30,0x23,0x02,0x01,0x00,0x04,0x03,0x79,0x6C,0x63,(byte)0xA0,0x19,0x02,0x01,0x0F,0x02,0x01,0x00,0x02,0x01,0x00,0x30,0x0E,0x30,0x0C,0x06,0x08 ,0x2B,0x06,0x01 ,0x02,0x01,0x0B,0x08,0x00,0x05,0x00};

        Message message = decoder.getSnmpMessageValue(b);
        System.out.println(message);

    }

}
